var trainTitle = "";
var trainContent = "";
var trainType = "";
var trainDate = "";
var trainAddressCode="";
var trainAddress = "";
var trainTeacher = "";
var sex = "";
var phone = "";
var trainObject = "";
var trainEvaluate = "";
var trainPeoples = "";
$(document).ready(function () {
            fillCounty("520600000000","trainAddressCode");
});

function addProducts() {


    trainTitle = $("#trainTitle").val();
    trainContent = $("#trainContent").val();

    trainType = $("#trainType option:selected").val();
    trainObject =  $("#trainObject").val();
     trainEvaluate =  $("#trainEvaluate").val();

    trainDate = $("#trainDate").val();
    trainAddress = $("#trainAddress").val();
    trainAddressCode=$("#trainAddressCode option:selected").val();
    trainTeacher = $("#trainTeacher").val();
    sex =  $("#sex option:selected").val();;
    phone =  $("#phone").val();

    trainPeoples =  $("#trainPeoples").val();
    var data = {
        "trainTitle": trainTitle,
        "trainContent": trainContent,
        "trainType": trainType,
        "trainObject": trainObject,
        "phone": phone,
        "trainDate": trainDate,
        "trainAddress": trainAddress,
        "trainAddressCode":trainAddressCode,
        "trainTeacher":trainTeacher ,
        "sex":sex ,
        "trainEvaluate": trainEvaluate,
        "trainPeoples": trainPeoples,
    }
    $.ajax({
        type: "POST",
        url: "/ebb/train/info/",
        data: JSON.stringify(data),
        contentType: "application/json",
        success: function (result) {
            ShowTip("添加培训信息成功", "success", 1500);
            setTimeout(function () {
                window.location = "trainManager.html";
            }, 2000);
        },
        error: function (err) {
            console.log(err);
            ShowTip("添加培训信息失败", "danger", 1500);//alert-success、.alert-info、.alert-warning、.alert-danger
        }
    });
}


function selectCate() {
   var _el = $(".secect-cate-level select");
   _el.on("change", function() {
       var changeClassify = $(this).children('option:selected').val();
       var arr=changeClassify.split(",");
       var get = this;
       var count = parseInt(arr[1])+1;
       $.ajax({
               type: "get",
               url: "/industrial/category/?id="+arr[0]+"&level="+count,
               dataType: "json",
               async: true,
               success: function (data) {
                   if(data.length > 0){
                       var result = data;
                       $(get).parent().next().children("select").html("");
                       for(var i=0;i<result.length;i++){
                           $(get).parent().next().children("select").append("<option value=\""+result[i].id+','+result[i].categoryLevel+"\">"+result[i].categoryName+"</option>");
                       }
                       $(get).parent().next().nextAll().children("select").html("");
                       $("#selectCatecomfirm").addClass("disabled");
                   }else {
                       $("#selectCatecomfirm").removeClass("disabled");
                   }
               }
           });
   });
}

var farmname = "";
var page = 1 ;
var size = 10 ;
var nctotalPages = 0;

function comments(){
    farmname= $("#farmName").val().trim();
    //getPoorNameHtml()
}


var farmName = "";
var phones = "";
var addrsss = "";
var classifyId = "";
function selectPoor(get) {
    $("#selectPoorModal").modal("hide");
    $('#newProduct').collapse('hide');
    $("#newProduct").modal("hide");
    farmName = $(get).parent("td").parent("tr").children("td:eq(0)").text();
//    phones = $(get).parent("td").parent("tr").children("td:eq(2)").text();
//    addrsss = $(get).parent("td").parent("tr").children("td:eq(3)").text();
//    ids = $(get).parent("td").parent("tr").children("td:eq(4)").text();
    $("#poorSet").html(farmName);
}
